package com.example.administrator.x3picturetransliteration.Home.Activity;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.x3picturetransliteration.Base.BaseActivity;
import com.example.administrator.x3picturetransliteration.Constants;
import com.example.administrator.x3picturetransliteration.R;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 关于我们
 * Created by Administrator on 2019/8/27.
 */

public class AboutUsActivity extends BaseActivity{

    @BindView(R.id.TitleText)TextView TitleText;
    @BindView(R.id.LButton)ImageView LButton;

    @BindView(R.id.nameText)TextView nameText;
    @BindView(R.id.VersionNumberText)TextView VersionNumberText;
    @BindView(R.id.gsText)TextView gsText;

    @Override
    public int intiLayout() {
        return R.layout.home_activity_about_us;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        TitleText.setText("关于我们");
        LButton.setImageResource(R.mipmap.home_backw);

        if (Constants.getConstants().getmAppDataBean().getAppName()!=null)nameText.setText(Constants.getConstants().getmAppDataBean().getAppName());

        if (Constants.getConstants().getmAppDataBean().getAppVersion()!=null){

            VersionNumberText.setText(Constants.getConstants().getmAppDataBean().getAppVersion());
        }else {

            VersionNumberText.setText("V" + packageName());
        }

        if (Constants.getConstants().getmAppDataBean().getCompanyName()!=null)gsText.setText(Constants.getConstants().getmAppDataBean().getCompanyName());
    }

    /** 返回 */
    @OnClick(R.id.left_button)
    public void left_buttonClick(){

        finish();
    }

    public String packageName() {
        PackageManager manager = getPackageManager();
        String name = null;
        try {
            PackageInfo info = manager.getPackageInfo(getPackageName(), 0);
            name = info.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }

        return name;
    }
}
